var _visitor_article_js = {
    template:'<div class="article-title">{{ d.title }}</div>\n' +
    '    <hr class="layui-bg-orange">\n' +
    '    <div class="article-info">\n' +
    '        <ul>\n' +
    '            <li>发布时间：{{ d.postdate }}</li>\n' +
    '            <li>来源：{{ d.source }}</li>\n' +
    '            <li>类型：{{ d.typeName }}</li>\n' +
    '        </ul>\n' +
    '    </div>\n' +
    '    <hr class="layui-bg-orange">\n' +
    '    <div class="article-content">\n' +
    '        <span>{{ d.text }}</span>\n' +
    '        <p class="autor">\n' +
    '            <span class="viewnum f_r">（{{ d.browsecount }}）</span>' +
    '            <a class="article_endorse" href="/article/endorse.action?id={{ d.id }}"> ' +
    '               <span id="article_endorse_span" class="pingl f_r">（{{ d.endorsecount }}）</span>\n' +
    '            </a>\n' +
    '        </p>\n' +
    '    </div>',

    index:'<div id="visitor_article"></div>',

    laytpl: null,
    init: function () {
        $('#main_content_div').html(_visitor_article_js.index);
        _visitor_article_js.article_init();
        _visitor_article_js.article_btn();
    },
    article_init: function () {
        var _par = window.location.search.substring(1);
        $.post('/article/getById.action?_=1'+'&'+_par,function (data) {
            var date = new Date(parseInt(data.postdate));
            data.postdate = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
            data.typeName = data.type.name;
            _visitor_article_js.laytpl(_visitor_article_js.template).render(data, function(html){
                $('#visitor_article').html(html);
                $('.article_endorse').on('click', function () {
                    $.post(this.toString(),function (data) {
                        $('#article_endorse_span').html('');
                        $('#article_endorse_span').append('（'+data+'）');
                    });
                    return false;
                });
            });
        });
    },
    article_btn: function () {
    }
}